package com.misakyanls.examples.lists;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class MergeLists {
	public static <T> List<T> merge(List<T> l1, List<T> l2) {
		List<T> result = new ArrayList<T>(l1);

		for (T e : l2) {
			if (!l1.contains(e))
				result.add(e);
		}

		return result;
	}

	public static <T> List<T> merge2(List<T> l1, List<T> l2) {
		Set<T> result = new HashSet<T>(l1);
		result.addAll(l2);

		return new ArrayList<T>(result);
	}

}
